//
//  CYProjectDetail_PhonePop1View.m
//  cyydt
//
//  Created by chu on 2019/1/24.
//  Copyright © 2019 chu. All rights reserved.
//

#import "CYProjectDetail_PhonePop1View.h"

@implementation CYProjectDetail_PhonePop1View

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        NSArray *nibView =  [[NSBundle mainBundle] loadNibNamed:@"CYProjectDetail_PhonePop1View" owner:self options:nil];
        UIView *backView = [nibView objectAtIndex:0];
        backView.frame = frame;
        backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0];
        [self addSubview:backView];
    }
    return self;
}

- (void)awakeFromNib{
    [super awakeFromNib];
    
    self.backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.2];
    self.tonghuaBtn.layer.cornerRadius = 2;
    self.tonghuaBtn.layer.masksToBounds = YES;
    
}

- (IBAction)tonghua:(UIButton *)sender {
    if (self.phoneTF.text.length == 0) {
        [[UIApplication sharedApplication].keyWindow makeToast:@"请输入您的手机号" duration:1.5 position:CSToastPositionCenter];
        return;
    }
    if (self.block) {
        self.block(self.phoneTF.text);
        [self dismiss];
    }
}

- (IBAction)close:(UIButton *)sender {
    [self dismiss];
}

- (void)show{
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self];
}

- (void)dismiss{
    [self removeFromSuperview];
}

@end
